package com.utils;

public class PlcSymbols {

    ///find type of address (I, Q, IB, QB)
	static public String getAddressType(String sAddress)	{

		char[] chars=sAddress.toCharArray();
		char[] aAddressType = new char[5];
		Character[] aAddress=new Character[chars.length];

		for (int i = 0; i < chars.length; i++) {
			aAddress[i]=chars[i];
		}
		short k = 0;
		for (int j = 0; j < aAddress.length; j++)	{
			if (Character.isLetter(aAddress[j]))	{
				aAddressType[k] = aAddress[j];
				k++;
			}
		}

		StringBuilder sb = new StringBuilder(aAddressType.length);
		for (Character c : aAddressType)
			sb.append(c.charValue());

		String str = sb.toString().trim();

		return str;
	}
	
    static public float getAddress(String sAddress) {

    	float fNum = 0;

    	String sAddress1 = sAddress.replaceAll("[a-zA-Z]", "");
    	String sAddress2 = sAddress1.replaceAll("\\s+", "");
    	
  		fNum = Float.parseFloat(sAddress2);
    	
    	return fNum;
    }
}